﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SpeakOut.Lib;

namespace SpeakOut.Model
{
    [Serializable]
    public class Category
    {
        public virtual Guid CategoryId { get; set; }

        public virtual string Name { get; set; }

        public virtual IList<Post> Posts { get; set; }

        public Category()
        {
            CategoryId = Guid.Empty;
            Posts = new List<Post>();
        }

        private bool Equals(Category other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return other.CategoryId.Equals(CategoryId);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != typeof (Category)) return false;
            return Equals((Category) obj);
        }

        public override int GetHashCode()
        {
            return CategoryId.GetHashCode();
        }
    }
}
